home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 2
/
Amiga Tools 2.iso
/
grafik
/
triton
/
demos
/
demo
/
demo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-04-09
|
38KB
|
1,161 lines
/*
* Triton - The object oriented GUI creation system for the Amiga
* Written by Stefan Zeiger in 1993-1994
*
* (c) 1993-1994 by Stefan Zeiger
* You are hereby allowed to use this source or parts of it for
* creating programs for AmigaOS which use the Triton GUI creation
* system. All other rights reserved.
*
* demo.c - Triton demo program
*
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////// Include our stuff //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <libraries/triton.h>
#include <proto/triton.h>
#include <proto/dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////// Global variables //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct TR_Project *main_project;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////// Window 'groups' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
ProjectDefinition(groups_trwintags)
{
WindowTitle("Groups"), WindowPosition(TRWP_CENTERDISPLAY), WindowUnderscore("~"), WindowID(1),
VertGroupA,
Space,
NamedSeparator("TRGR_PROPSHARE (default)"),
Space,
HorizGroupC,
Space,
Button("Short",1),
Space,
Button("And much, much longer...",2),
Space,
EndGroup,
Space,
NamedSeparator("TRGR_EQUALSHARE"),
Space,
HorizGroupEC,
Space,
Button("Short",3),
Space,
Button("And much, much longer...",4),
Space,
EndGroup,
Space,
NamedSeparator("TRGR_PROPSPACES"),
Space,
HorizGroupSC,
Space,
Button("Short",5),
Space,
Button("And much, much longer...",6),
Space,
EndGroup,
Space,
NamedSeparator("TRGR_ARRAY"),
Space,
LineArray,
BeginLine,
Space,
Button("Short",7),
Space,
Button("And much, much longer...",8),
Space,
EndLine,
Space,
BeginLine,
Space,
Button("Not so short",9),
Space,
Button("And a bit longer...",10),
Space,
EndLine,
Space,
BeginLine,
Space,
Button("foo bar",12),
Space,
Button("42",13),
Space,
EndLine,
EndArray,
Space,
EndGroup,
EndProject
};
VOID do_groups(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
struct TR_Project *groups_project;
if(groups_project=TR_OpenProject(Application,groups_trwintags))
{
TR_LockProject(main_project);
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==groups_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
}
TR_ReplyMsg(trmsg);
}
}
TR_UnlockProject(main_project);
TR_CloseProject(groups_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////// Window 'menus' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct TagItem menus_trwintags[]=
{
WindowID(2), WindowTitle("Menus"),
TRMN_Title, (ULONG) "A menu",
TRMN_Item, (ULONG) "A simple item", TRAT_ID, 1,
TRMN_Item, (ULONG) "Another item", TRAT_ID, 2,
TRMN_Item, (ULONG) "And now... a barlabel", TRAT_ID, 3,
TRMN_Item, (ULONG) TRMN_BARLABEL,
TRMN_Item, (ULONG) "1_An item with a shortcut", TRAT_ID, 4,
TRMN_Item, (ULONG) "2_Another one", TRAT_ID, 5,
TRMN_Item, (ULONG) "3_And number 3", TRAT_ID, 6,
TRMN_Item, (ULONG) TRMN_BARLABEL,
TRMN_Item, (ULONG) "_F1_And under OS3.0: Extended command keys", TRAT_ID, 6,
TRMN_Item, (ULONG) "_F2_Another one", TRAT_ID, 7,
TRMN_Item, (ULONG) TRMN_BARLABEL,
TRMN_Item, (ULONG) "How do you like submenus?",
TRMN_Sub, (ULONG) "G_Great!", TRAT_ID, 8,
TRMN_Sub, (ULONG) "F_Fine", TRAT_ID, 9,
TRMN_Sub, (ULONG) "D_Don't know", TRAT_ID, 10,
TRMN_Sub, (ULONG) "N_Not so fine", TRAT_ID, 11,
TRMN_Sub, (ULONG) "P_Puke!", TRAT_ID, 12,
TRMN_Title, (ULONG) "Another menu",
TRMN_Item, (ULONG) "This item is ghosted", TRMN_Flags, TRMF_DISABLED, TRAT_ID, 100,
TRMN_Item, (ULONG) TRMN_BARLABEL,
TRMN_Item, (ULONG) "Item 1 is checked", TRMN_Flags, TRMF_CHECKED, TRAT_ID, 13,
TRMN_Item, (ULONG) "Item 2 can be checked, too", TRMN_Flags, TRMF_CHECKIT, TRAT_ID, 14,
TRMN_Title, (ULONG) "Ghosted menu",
TRMN_Flags, (ULONG) TRMF_DISABLED,
TRMN_Item, (ULONG) "Item 1", TRAT_ID, 101,
TRMN_Item, (ULONG) "Item 2", TRAT_ID, 102,
TAG_END
};
VOID do_menus(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
struct TR_Project *menus_project;
if(menus_project=TR_OpenProject(Application,menus_trwintags))
{
TR_LockProject(main_project);
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==menus_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
case TRMS_NEWVALUE:
printf("The new value of object %d is %d.\n",trmsg->trm_ID,trmsg->trm_Data);
break;
case TRMS_ACTION:
printf("Object %d has triggered an action.\n",trmsg->trm_ID);
break;
}
TR_ReplyMsg(trmsg);
}
}
TR_UnlockProject(main_project);
TR_CloseProject(menus_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////// Window 'gadgets' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
STRPTR cycle_entries[]=
{
"Entry 0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
NULL
};
struct TagItem gadgets_trwintags[]=
{
WindowID(3),
WindowTitle("Gadgets"),
WindowPosition(TRWP_CENTERDISPLAY),
TRGR_Vert, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_EQUALSHARE|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Line, (ULONG) TROF_HORIZ,
TROB_Space, (ULONG) NULL,
TROB_Text, (ULONG) NULL, TRAT_Text, (ULONG) "GadTools", TRAT_Flags, (ULONG) TRTX_3D,
TROB_Space, (ULONG) NULL,
TROB_Line, (ULONG) TROF_HORIZ,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_EQUALSHARE|TRGR_ALIGN|TRGR_CENTER,
TRGR_Horiz, (ULONG) TRGR_PROPSPACES|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_CheckBox, (ULONG) NULL,
TRAT_ID, (ULONG) 1,
TRAT_Value, (ULONG) TRUE,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSPACES|TRGR_ALIGN|TRGR_CENTER,
TROB_Text, (ULONG) NULL,
TRAT_Text, (ULONG) "_Checkbox",
TRAT_ID, (ULONG) 1,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_EQUALSHARE|TRGR_ALIGN|TRGR_CENTER,
TRGR_Horiz, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Slider, (ULONG) NULL,
TRAT_ID, (ULONG) 4,
TRSL_Min, (ULONG) 1,
TRSL_Max, (ULONG) 3,
TRAT_Value, (ULONG) 1,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSPACES|TRGR_ALIGN|TRGR_CENTER,
TROB_Text, (ULONG) NULL,
TRAT_Text, (ULONG) "_Slider: ",
TRAT_ID, (ULONG) 4,
TROB_Text, (ULONG) NULL,
TRAT_Value, (ULONG) 1,
TRAT_ID, (ULONG) 4,
TRAT_MinWidth, (ULONG) 3,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_EQUALSHARE|TRGR_ALIGN|TRGR_CENTER,
TRGR_Horiz, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Scroller, (ULONG) NULL,
TRAT_ID, (ULONG) 5,
TRAT_Value, (ULONG) 2,
TRSC_Total, (ULONG) 7,
TRSC_Visible, (ULONG) 3,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSPACES|TRGR_ALIGN|TRGR_CENTER,
TROB_Text, (ULONG) NULL,
TRAT_Text, (ULONG) "Sc_roller: ",
TRAT_ID, (ULONG) 5,
TROB_Text, (ULONG) NULL,
TRAT_Value, (ULONG) 2,
TRAT_ID, (ULONG) 5,
TRAT_MinWidth, (ULONG) 3,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_EQUALSHARE|TRGR_ALIGN|TRGR_CENTER,
TRGR_Horiz, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Palette, (ULONG) NULL,
TRAT_ID, (ULONG) 3,
TRAT_Value, (ULONG) 1,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSPACES|TRGR_ALIGN|TRGR_CENTER,
TROB_Text, (ULONG) NULL,
TRAT_Text, (ULONG) "_Palette: ",
TRAT_ID, (ULONG) 3,
TROB_Text, (ULONG) NULL,
TRAT_Value, (ULONG) 1,
TRAT_ID, (ULONG) 3,
TRAT_MinWidth, (ULONG) 3,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_EQUALSHARE|TRGR_ALIGN|TRGR_CENTER,
TRGR_Horiz, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Cycle, (ULONG) cycle_entries,
TRAT_ID, (ULONG) 6,
TRAT_Value, (ULONG) 4,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSPACES|TRGR_ALIGN|TRGR_CENTER,
TROB_Text, (ULONG) NULL,
TRAT_Text, (ULONG) "C_ycle: ",
TRAT_ID, (ULONG) 6,
TROB_Text, (ULONG) NULL,
TRAT_Value, (ULONG) 4,
TRAT_ID, (ULONG) 6,
TRAT_MinWidth, (ULONG) 3,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_EQUALSHARE|TRGR_ALIGN|TRGR_CENTER,
TRGR_Horiz, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_String, (ULONG) "foo bar",
TRAT_ID, (ULONG) 7,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSPACES|TRGR_ALIGN|TRGR_CENTER,
TROB_Text, (ULONG) NULL,
TRAT_Text, (ULONG) "S_tring",
TRAT_ID, (ULONG) 7,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_EQUALSHARE|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Line, (ULONG) TROF_HORIZ,
TROB_Space, (ULONG) NULL,
TROB_Text, (ULONG) NULL, TRAT_Text, (ULONG) "BOOPSI", TRAT_Flags, (ULONG) TRTX_3D,
TROB_Space, (ULONG) NULL,
TROB_Line, (ULONG) TROF_HORIZ,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Button, (ULONG) NULL, TRAT_ID, 2, TRAT_Text, (ULONG) "_Button",
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSPACES|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Text, (ULONG) NULL, TRAT_Text, (ULONG) "_File:", TRAT_ID, 10,
TROB_Space, (ULONG) NULL,
TROB_Button, (ULONG) TRBT_GETFILE, TRAT_ID, 10, TRAT_Text, (ULONG) "",
TROB_Space, (ULONG) NULL,
TROB_Text, (ULONG) NULL, TRAT_Text, (ULONG) "_Drawer:", TRAT_ID, 11,
TROB_Space, (ULONG) NULL,
TROB_Button, (ULONG) TRBT_GETDRAWER, TRAT_ID, 11, TRAT_Text, (ULONG) "",
TROB_Space, (ULONG) NULL,
TROB_Text, (ULONG) NULL, TRAT_Text, (ULONG) "_Entry:", TRAT_ID, 12,
TROB_Space, (ULONG) NULL,
TROB_Button, (ULONG) TRBT_GETENTRY, TRAT_ID, 12, TRAT_Text, (ULONG) "",
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TAG_END
};
VOID do_gadgets(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
struct TR_Project *gadgets_project;
if(gadgets_project=TR_OpenProject(Application,gadgets_trwintags))
{
TR_LockProject(main_project);
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==gadgets_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
}
TR_ReplyMsg(trmsg);
}
}
TR_UnlockProject(main_project);
TR_CloseProject(gadgets_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////// Window 'disabling' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct TagItem disabling_trwintags[]=
{
WindowID(4), WindowTitle("Disabling"), WindowPosition(TRWP_CENTERDISPLAY),
TRGR_Vert, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_CheckBox, (ULONG) NULL, TRAT_ID, 1, TRAT_Value, TRUE,
TROB_Space, (ULONG) NULL,
TROB_Text, (ULONG) NULL, TRAT_Text, (ULONG) "_Disable", TRAT_ID, 1,
TRGR_Horiz, (ULONG) TRGR_PROPSPACES,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_EQUALSHARE|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Line, (ULONG) TROF_HORIZ,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_CheckBox, (ULONG) NULL, TRAT_Value, TRUE, TRAT_ID, 2, TRAT_Disabled, TRUE,
TROB_Space, (ULONG) NULL,
TROB_Text, (ULONG) NULL, TRAT_Text, (ULONG) "_Checkbox", TRAT_ID, 2,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_Horiz, (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_CENTER,
TROB_Space, (ULONG) NULL,
TROB_Button, (ULONG) NULL, TRAT_Text, (ULONG) "_Button", TRAT_ID, 3, TRAT_Disabled, TRUE,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TROB_Space, (ULONG) NULL,
TRGR_End, (ULONG) NULL,
TAG_END
};
VOID do_disabling(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
struct TR_Project *disabling_project;
if(disabling_project=TR_OpenProject(Application,disabling_trwintags))
{
TR_LockProject(main_project);
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==disabling_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
case TRMS_NEWVALUE:
if(trmsg->trm_ID==1)
{
TR_SetAttribute(disabling_project,2,TRAT_Disabled,trmsg->trm_Data);
TR_SetAttribute(disabling_project,3,TRAT_Disabled,trmsg->trm_Data);
}
}
TR_ReplyMsg(trmsg);
}
}
TR_UnlockProject(main_project);
TR_CloseProject(disabling_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////// Window 'text' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
ProjectDefinition(text_trwintags)
{
WindowID(5), WindowTitle("Text"), WindowPosition(TRWP_CENTERDISPLAY),
VertGroupA,
Space, CenteredText("Normal text"),
Space, CenteredTextH("Highlighted text"),
Space, CenteredText3("3-dimensional text"),
Space, CenteredTextB("Bold text"),
Space, CenteredText("A _shortcut"),
Space, CenteredInteger(42),
Space, EndGroup, EndProject
};
VOID do_text(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
struct TR_Project *text_project;
if(text_project=TR_OpenProject(Application,text_trwintags))
{
TR_LockProject(main_project);
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==text_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
}
TR_ReplyMsg(trmsg);
}
}
TR_UnlockProject(main_project);
TR_CloseProject(text_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////// Window 'connections' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
ProjectDefinition(connections_trwintags)
{
WindowID(6), WindowTitle("Connections"), WindowPosition(TRWP_CENTERDISPLAY),
VertGroupA,
Space,
NamedSeparatorI("_Checkmarks",1),
Space,
HorizGroupSAC,
Space, CheckBox(1),
Space, CheckBox(1),
Space, CheckBox(1),
Space, EndGroup,
Space,
HorizGroupSAC,
Space, CheckBox(1),
Space, CheckBox(1),
Space, CheckBox(1),
Space, EndGroup,
Space,
HorizGroupSAC,
Space, CheckBox(1),
Space, CheckBox(1),
Space, CheckBox(1),
Space, EndGroup,
Space,
NamedSeparatorI("_Slider and Progress indicator",2),
Space,
HorizGroupAC,
Space,
SliderGadget(0,10,8,2),
Space,
Integer3(8),TRAT_ID,2,TRAT_MinWidth,3,
Space,
EndGroup,
Space,
HorizGroupAC,
Space,
TextN("0%"),
Space,
Progress(10,8,2),
Space,
TextN("100%"),
Space,
EndGroup,
Space,
EndGroup, EndProject
};
VOID do_connections(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
struct TR_Project *connections_project;
if(connections_project=TR_OpenProject(Application,connections_trwintags))
{
TR_LockProject(main_project);
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==connections_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
}
TR_ReplyMsg(trmsg);
}
}
TR_UnlockProject(main_project);
TR_CloseProject(connections_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////// Window 'backfill' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
ProjectDefinition(backfill_trwintags)
{
WindowID(7), WindowTitle("Backfill"), WindowPosition(TRWP_CENTERDISPLAY),
VertGroupA,
Space, CenteredText("Each window and"),
SpaceS, CenteredText("FrameBox can have"),
SpaceS, CenteredText("one of the following"),
SpaceS, CenteredText("backfill patterns"),
Space, HorizGroupA,
Space, FrameBox, ObjectBackfillS, SpaceB,
Space, FrameBox, ObjectBackfillSA, SpaceB,
Space, FrameBox, ObjectBackfillSF, SpaceB,
Space, EndGroup,
Space, HorizGroupA,
Space, FrameBox, ObjectBackfillSB, SpaceB,
Space, FrameBox, ObjectBackfillA, SpaceB,
Space, FrameBox, ObjectBackfillAF, SpaceB,
Space, EndGroup,
Space, HorizGroupA,
Space, FrameBox, ObjectBackfillAB, SpaceB,
Space, FrameBox, ObjectBackfillF, SpaceB,
Space, FrameBox, ObjectBackfillFB, SpaceB,
Space, EndGroup,
Space, EndGroup, EndProject
};
VOID do_backfill(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
struct TR_Project *backfill_project;
if(backfill_project=TR_OpenProject(Application,backfill_trwintags))
{
TR_LockProject(main_project);
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==backfill_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
}
TR_ReplyMsg(trmsg);
}
}
TR_UnlockProject(main_project);
TR_CloseProject(backfill_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////// Window 'appwindow' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
ProjectDefinition(appwindow_trwintags)
{
WindowID(8), WindowTitle("AppWindow"), WindowPosition(TRWP_CENTERDISPLAY), WindowBackfillFB,
VertGroupA,
Space, CenteredText("This window is an application window."),
SpaceS, CenteredText("Drop icons into the window or into"),
SpaceS, CenteredText("the icon drop boxes below and see"),
SpaceS, CenteredText("what will happen..."),
Space, HorizGroupA,
Space, DropBox(1),
Space, DropBox(2),
Space, EndGroup,
Space, EndGroup, EndProject
};
VOID do_appwindow(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
struct TR_Project *appwindow_project;
UBYTE reqstr[200],dirname[100];
if(appwindow_project=TR_OpenProject(Application,appwindow_trwintags))
{
TR_LockProject(main_project);
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==appwindow_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
case TRMS_ICONDROPPED:
dirname[0]=0;
NameFromLock(((struct AppMessage *)(trmsg->trm_Data))->am_ArgList->wa_Lock,dirname,100);
AddPart(dirname,((struct AppMessage *)(trmsg->trm_Data))->am_ArgList->wa_Name,100);
switch(trmsg->trm_ID)
{
case 1:
sprintf(reqstr,"Icon(s) dropped into the left box.\tName of first dropped icon:\n%%3%s",dirname);
break;
case 2:
sprintf(reqstr,"Icon(s) dropped into the right box.\tName of first dropped icon:\n%%3%s",dirname);
break;
default:
sprintf(reqstr,"Icon(s) dropped into the window.\tName of first dropped icon:\n%%3%s",dirname);
}
TR_EasyRequestTags(Application,reqstr,"_Ok",
TREZ_LockProject,appwindow_project,TREZ_Title,"AppWindow report",TREZ_Activate,TRUE,TAG_END);
break;
}
TR_ReplyMsg(trmsg);
}
}
TR_UnlockProject(main_project);
TR_CloseProject(appwindow_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////// Window 'lists' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct TR_Dimensions lists_dim;
extern struct MinList LVList1;
extern struct MinList LVList2;
extern struct MinList LVList3;
struct Node LVNodes1[] =
{
{ &LVNodes1[1], (struct Node *)&LVList3.mlh_Head, 0, 0, "This is a" },
{ &LVNodes1[2], &LVNodes1[0], 0, 0, "READ" },
{ &LVNodes1[3], &LVNodes1[1], 0, 0, "ONLY" },
{ &LVNodes1[4], &LVNodes1[2], 0, 0, "Listview" },
{ &LVNodes1[5], &LVNodes1[3], 0, 0, "gadget" },
{ &LVNodes1[6], &LVNodes1[4], 0, 0, "using the" },
{ &LVNodes1[7], &LVNodes1[5], 0, 0, "fixed-width" },
{ &LVNodes1[ 8], &LVNodes1[ 6], 0, 0, "font." },
{ &LVNodes1[ 9], &LVNodes1[ 7], 0, 0, "" },
{ &LVNodes1[10], &LVNodes1[ 8], 0, 0, "This window" },
{ &LVNodes1[11], &LVNodes1[ 9], 0, 0, "uses a" },
{ &LVNodes1[12], &LVNodes1[10], 0, 0, "dimensions" },
{ &LVNodes1[13], &LVNodes1[11], 0, 0, "structure," },
{ &LVNodes1[14], &LVNodes1[12], 0, 0, "so it will" },
{ &LVNodes1[15], &LVNodes1[13], 0, 0, "remember" },
{ &LVNodes1[16], &LVNodes1[14], 0, 0, "its" },
{ &LVNodes1[17], &LVNodes1[15], 0, 0, "position" },
{ &LVNodes1[18], &LVNodes1[16], 0, 0, "when you" },
{ (struct Node *)&LVList3.mlh_Tail, &LVNodes1[17],0, 0, "reopen it." }
};
struct Node LVNodes2[] =
{
{ &LVNodes2[1], (struct Node *)&LVList3.mlh_Head, 0, 0, "This is a" },
{ &LVNodes2[2], &LVNodes2[0], 0, 0, "SELECT" },
{ &LVNodes2[3], &LVNodes2[1], 0, 0, "Listview" },
{ &LVNodes2[4], &LVNodes2[2], 0, 0, "gadget." },
{ &LVNodes2[5], &LVNodes2[3], 0, 0, "Use the" },
{ &LVNodes2[6], &LVNodes2[4], 0, 0, "numeric" },
{ &LVNodes2[7], &LVNodes2[5], 0, 0, "key pad to" },
{ &LVNodes2[8], &LVNodes2[6], 0, 0, "move" },
{ (struct Node *)&LVList3.mlh_Tail, &LVNodes2[7], 0, 0, "around." }
};
struct Node LVNodes3[] =
{
{ &LVNodes3[1], (struct Node *)&LVList3.mlh_Head, 0, 0, "This is a" },
{ &LVNodes3[2], &LVNodes3[0], 0, 0, "SHOW" },
{ &LVNodes3[3], &LVNodes3[1], 0, 0, "SELECTED" },
{ &LVNodes3[4], &LVNodes3[2], 0, 0, "Listview" },
{ &LVNodes3[5], &LVNodes3[3], 0, 0, "gadget." },
{ &LVNodes3[6], &LVNodes3[4], 0, 0, "This list" },
{ &LVNodes3[7], &LVNodes3[5], 0, 0, "is a bit" },
{ &LVNodes3[8], &LVNodes3[6], 0, 0, "longer, so" },
{ &LVNodes3[9], &LVNodes3[7], 0, 0, "that you" },
{ &LVNodes3[10],&LVNodes3[8], 0, 0, "can try the" },
{ &LVNodes3[11],&LVNodes3[9], 0, 0, "other" },
{ &LVNodes3[12],&LVNodes3[10], 0, 0, "keyboard" },
{ (struct Node *)&LVList3.mlh_Tail, &LVNodes3[11],0, 0, "shortcuts." }
};
struct List LVList1=
{
(struct Node *)&LVNodes1[0],
(struct Node *)NULL,
(struct Node *)&LVNodes1[18],
0,0
};
struct List LVList2=
{
(struct Node *)&LVNodes2[0],
(struct Node *)NULL,
(struct Node *)&LVNodes2[8],
0,0
};
struct List LVList3=
{
(struct Node *)&LVNodes3[0],
(struct Node *)NULL,
(struct Node *)&LVNodes3[12],
0,0
};
struct TagItem lists_trwintags[]=
{
WindowID(9), WindowTitle("Lists"), WindowPosition(TRWP_CENTERDISPLAY), WindowDimensions(&lists_dim),
VertGroupEA,
Space,
NamedSeparatorI("_Read only",1),
Space,
HorizGroupA,
Space,
FWListROCN(&LVList1,1,0),
Space,
EndGroup,
Space,
NamedSeparatorI("_Select",2),
Space,
HorizGroupA,
Space,
ListSelC(&LVList2,2,0),
Space,
EndGroup,
Space,
NamedSeparatorI("S_how selected",3),
Space,
HorizGroupA,
Space,
ListSSN(&LVList3,3,0,1),
Space,
EndGroup,
Space,
EndGroup,
EndProject
};
VOID do_lists(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
struct TR_Project *lists_project;
if(lists_project=TR_OpenProject(Application,lists_trwintags))
{
TR_LockProject(main_project);
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==lists_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
}
TR_ReplyMsg(trmsg);
}
}
TR_UnlockProject(main_project);
TR_CloseProject(lists_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////// Window 'about' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Note: This could be done even simpler with TR_EasyRequest().
// ~~~~~ It is done with TR_AutoRequest() to show you how this works.
// See window 'AppWindow' for a TR_EasyRequest() example.
ProjectDefinition(about_trwintags)
{
BeginRequester("About...",TRWP_CENTERDISPLAY),
VertGroupA, Space, CenteredText3("Triton Demo"),
SpaceS, CenteredText("© 1993-1994 by Stefan Zeiger"),
Space, HorizSeparator,
Space, CenteredText("This program is using the"),
SpaceS, CenteredText("Triton GUI creation system"),
SpaceS, CenteredText("which is © by Stefan Zeiger"),
Space, EndGroup,
BeginRequesterGads,
CenteredButtonRE("_Ok",1),
EndRequester
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////// Window 'main' //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
ProjectDefinition(main_trwintags)
{
WindowID(10), WindowTitle("Triton Demo"), WindowBackfillFB, WindowPosition(TRWP_CENTERDISPLAY),
BeginMenu("Project"),
MenuItem("?_About...",101),
ItemBarlabel,
MenuItem("Q_Quit",102),
VertGroupA,
Space, CenteredText3("T · r · i · t · o · n"),
Space, CenteredText3("The object oriented GUI creation system"),
Space, CenteredText("Demo program"),
Space, CenteredText("Written and © 1993-1994 by Stefan Zeiger"),
Space, HorizSeparator,
Space, HorizGroupEA,
Space, Button("_Gadgets",1),
Space, Button("G_roups",2),
Space, Button("_Text",3),
Space, EndGroup,
Space, HorizGroupEA,
Space, Button("_Connections",4),
Space, Button("_Backfill",5),
Space, Button("_Disabling",6),
Space, EndGroup,
Space, HorizGroupEA,
Space, Button("_AppWindow",7),
Space, Button("_Menus",8),
Space, Button("_Lists",9),
Space, EndGroup,
Space, EndGroup, EndProject
};
VOID do_main(VOID)
{
BOOL close_me=FALSE;
struct TR_Message *trmsg;
if(main_project=TR_OpenProject(Application,main_trwintags))
{
while(!close_me)
{
TR_Wait(Application,NULL);
while(trmsg=TR_GetMsg(Application))
{
if(trmsg->trm_Project==main_project) switch(trmsg->trm_Class)
{
case TRMS_CLOSEWINDOW:
close_me=TRUE;
break;
case TRMS_ERROR:
puts(TR_GetErrorString(trmsg->trm_Data));
break;
case TRMS_ACTION:
switch(trmsg->trm_ID)
{
case 1:
do_gadgets();
break;
case 2:
do_groups();
break;
case 3:
do_text();
break;
case 4:
do_connections();
break;
case 5:
do_backfill();
break;
case 6:
do_disabling();
break;
case 7:
do_appwindow();
break;
case 8:
do_menus();
break;
case 9:
do_lists();
break;
case 101:
TR_AutoRequest(Application,main_project,about_trwintags);
break;
case 102:
close_me=TRUE;
}
break;
}
TR_ReplyMsg(trmsg);
}
}
TR_CloseProject(main_project);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////// Main function //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(void)
{
if(TR_OpenTriton(0,TRCA_Name,"TritonDemo",TRCA_LongName,"Triton demo",TRCA_Version,"1.0",TAG_END))
{
do_main();
TR_CloseTriton();
return 0;
}
puts("Can't open triton.library.");
return 20;
}